package ac.il.technion.cs236635.project.core;

import javax.jws.WebMethod;
import javax.jws.WebService;

import org.apache.log4j.Logger;

@WebService
public class CloudWorker {

	private Logger log = Logger.getLogger( CloudWorker.class);
	
	@WebMethod( operationName = "submitLowJob")
	public void submitLowJob( final ServerJob job) {
		int num = JobsQueue.getInstance().getLowJobsNum();
		log.info( "RECEIVING: Received submission to low queue of job with id: " + job.getJobId( ) + " jobs in queue: " + num);
		job.setJobType( JobType.LOW_PRIORITY);
		job.setStartTime( System.currentTimeMillis());
		JobsQueue.getInstance( ).pushLowPriorityJob( job);
	}
	
	@WebMethod( operationName = "submitHighJob")
	public void submitHighJob( final ServerJob job) {
		int num = JobsQueue.getInstance().getHighJobsNum();
		log.info( "RECEIVING: Received submission to high queue of job with id: " + job.getJobId( ) + " jobs in queue: " + num);
		job.setJobType( JobType.HIGH_PRIORITY);
		job.setStartTime( System.currentTimeMillis());
		JobsQueue.getInstance( ).pushHighPriorityJob( job);
	}
}
